<%@page import="cn.sendto.model.ClassEntity"%>
<%@page import="cn.sendto.mapper.ClassMapper"%>
<%@page import="cn.sendto.mapper.StudentMapper"%>
<%@page import="cn.sendto.mapper.IRowMapper"%>
<%@page import="cn.sendto.model.StudentEntity"%>
<%@page import="java.util.List"%>
<%@page import="cn.sendto.dbhelper.DBHelper"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="getSession.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta charset="UTF-8">
		<title>学生列表页</title>
		<link rel="stylesheet" type="text/css" href="css/global.css"/>
		<style type="text/css">
			html,body{
				width: 100%;
				height: 100%;
				background-color: #DDDDDD;
			}
			.con{
				width: 95%;
				margin: 0 auto;
				border: 1px solid darkgrey;
				margin-top:3%;
			}
			.title{
				height: 30px;
				border-bottom: 1px dashed darkgray;
			}
			.title li{
				float: left;
				width: 9%;
				line-height: 30px;
				height: 30px;
				text-align: center;
				overflow: hidden;
			}
			
			a:hover{
				left: 1px;
				top: 1px;
				position: relative;
				color: blue;
				text-shadow: 3px 5px 4px #000000;
				color: royalblue;
			}
			ul:last-child{
				border-bottom: none;
			}
			ul:first-child{
			   font-weight: bold;
			   background-color: #CCC;
			}
		</style>
	</head>
	<body>
		<h4 style="text-align: center; margin-top: 3%;font-size:30px;">学生信息列表</h4>
		<div style="width:95%; text-align: right;"><a href="student_add.jsp"><span style="font-size:25px">添加学生</span></a></div>
		<div class="con">
			<ul class="title">
				<li>序号</li>
				<li>姓名</li>
				<li>性别</li>
				<li>年龄</li>
				<li>学号</li>
				<li>地址</li>
				<li>电话</li>
				<li>班级</li>
				<li>成绩</li>
				<li>修改</li>
				<li>删除</li>
			</ul>
			<%
				DBHelper helper = new DBHelper();
			
				IRowMapper mapper = new StudentMapper();
				
				String sql = "select * from studentinfo s,classinfo c where c.classid = s.classid";
				
				List<StudentEntity> list = helper.executeQuery(sql, mapper, null);
				
				helper.close();
				
				for(int i=0;i<list.size();i++){
				%>
			<ul class="title">
				<li><%=i+1 %></li>
				<li><%=list.get(i).getStudentName() %></li>
				<li>
				<%=list.get(i).getGender() %></li>
				<li><%=list.get(i).getAge() %></li>
				<li><%=list.get(i).getStudentno() %></li>
				<li title="<%=list.get(i).getAddress()%>"><%=list.get(i).getAddress()%></li>
				<li><%=list.get(i).getTel()%></li>
				<li title="<%=list.get(i).getClassName()%>"><%=list.get(i).getClassName()
				%></li>
				<li><a href="score_list.jsp?id=<%=list.get(i).getStudentId()%>">查看</a></li>
				<li><a href="modify.jsp?id=<%=list.get(i).getStudentId()%>">修改</a></li>
				<li><a href="delete.jsp?id=<%=list.get(i).getStudentId()%>" onclick="return confirm('你确定要删除引学生信息吗？')">删除</a></li>
			</ul>
				<% 
			      }
				helper.close();
			    %>
			    <%
			if(request.getAttribute("message")!=null){
			%>
				<script type="text/javascript">
					alert('<%=request.getAttribute("message")%>');
				</script>
			<% 
			}else{
				
			}
			%>
		</div>
		
	</body>
</html>
